<?php
if (!(defined('IN_IA'))) 
{
	exit('Access Denied');
}
class User_Model
{
	public function __construct()
	{
	}
	public function getOpenid() 
	{
		$userinfo = $this->getInfo(false, true);
		return $userinfo['openid'];
	}
	public function getInfo($base64 = false, $debug = false) 
	{
		global $_W;
		global $_GPC;
		$userinfo = array();
        load()->model('mc');
        $userinfo = mc_oauth_userinfo();
        $need_openid = true;

		if ($base64)
		{
			return urlencode(base64_encode(json_encode($userinfo)));
		}
		return $userinfo;
	}
	public function followed($openid = '') 
	{
		global $_W;
		$followed = !(empty($openid));
		if ($followed) 
		{
			$mf = pdo_fetch('select follow from ' . tablename('mc_mapping_fans') . ' where openid=:openid and uniacid=:uniacid limit 1', array(':openid' => $openid, ':uniacid' => $_W['uniacid']));
			$followed = $mf['follow'] == 1;
		}
		return $followed;
	}
}
?>